<?php
require("cfg.php");
require("function.php");
//var_dump($_POST);

$post_song_name=$_POST['name'];
$post_song_path=$_POST['path'];
$post_song_name=iconv("utf-8","gb2312",$post_song_name);
$post_song_path=iconv("utf-8","gb2312",$post_song_path);
$song_name_array=explode('&',$post_song_name);
$song_path_array=explode('&',$post_song_path);
//var_dump($song_name_array);
//var_dump($song_path_array);
if ($_POST['list']) {
	$list_id=$_POST['list'];
}
else {
$list_id=1;
}
$ip=get_ip();
$sql="DELETE FROM `user_list_record` WHERE `list_id` = '$list_id' AND `user_name` = 'test_user';";
mysql_query($sql);
for ($i=1;$i<count($song_name_array);$i++){
	if ($song_name_array[$i]) {
		$tmp_song_name=$song_name_array[$i];
		$tmp_song_path=$song_path_array[$i];
		$sql="INSERT INTO `user_list_record` (`id`, `list_id`, `user_name`, `song_name`, `song_path`, `creat_time`, `ip`) VALUES (NULL, '$list_id', 'test_user', '$tmp_song_name', '$tmp_song_path', NOW(), '$ip');";
		try {
		mysql_query($sql);
		echo "$iok!";
		}
		catch (Exception $e){
			//echo $e->getMessage();
		}
	}
}


?>